package com.atguigu.yygh.oss.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/oss/file")
@Api(value = "FileApiController",tags = "文件上传管理")
public class FileApiController {

    @Resource
    private FileService fileService;

    /**
     * 上传文件到阿里云oss
     */
    @PostMapping("fileUpload")
    @ApiOperation(value = "上传文件")
    public Result fileUpload(MultipartFile file) {
        //获取上传文件
        String url = fileService.upload(file);
        return new Result(url);
    }

}
